package com.zyp.composite;

public class TestComposite {

	public static void main(String[] args) {
		IComponent root=new Container("根节点");
		//创建两个第一层节点
		IComponent container1=new Container("第一层节点1");
		IComponent container2=new Container("第一层节点2");
		//添加到根节点中
		root.add(container1);
		root.add(container2);
		IComponent leaf1=new Leaf("第一层节点1- 叶子1");
		IComponent leaf2=new Leaf("第一层节点1- 叶子2");
		container1.add(leaf1);
		container1.add(leaf2);
		IComponent leaf3=new Leaf("第一层节点2- 叶子1");
		IComponent leaf4=new Leaf("第一层节点2- 叶子2");
		container2.add(leaf3);
		container2.add(leaf4);
		//第二层节点
		IComponent container3=new Container("第一层节点3");
		IComponent leaf5=new Leaf("第二层节点1- 叶子1");
		IComponent leaf6=new Leaf("第二层节点1- 叶子2");
		container2.add(container3);
		container3.add(leaf5);
		container3.add(leaf6);
		
		root.display(0);
		
	}
	
}
